#ifndef IO_H
#define IO_H

#include <string>
#include <vector>
#include "WordsLine.h"
#include "Database.h"
#include <sys/stat.h>

using namespace std;

enum { SHORT, LONG };


vector<WordsLine> readXml(string filename);
void writeXml(vector<WordsLine> data, string filename);



void writeDatabase(vector< pair<string, Descriptors > > prototypes, string filename);
vector< pair<string, Descriptors> > readDatabase(string filename);

pair<string, Descriptors > lineToPrototype(string line);
string prototypeToLine(pair<string, Descriptors > prototype);

void writeToCSV(vector< pair<string, Descriptors > > prototypes, string fileName, string type);
void writeAllToCSV(vector< pair<string, Descriptors > > prototypes);
vector<double> getValues(vector< pair<string, Descriptors > > prototypes, string type);
double getMinimum(vector<double> values);
double getMaximum(vector<double> values);
void writeAllHistogramsToCSV(vector< pair<string, Descriptors > > prototypes, int steps);
void writeToHistogramToCSV(vector< pair<string, Descriptors > > prototypes, string fileName, int steps, string type);
vector<pair<double, double> > GetHistogram(vector<double> values, unsigned steps);


vector< string > readDirectory(string pathname, int length=LONG );

void SaveLineImage(string folderName, WordsLine& line, PamImage& image);
void SaveWordImage(string folderName, Word& word, PamImage& image);
void SaveImage(string folderName, string fileName, PamImage& image);
#endif
